package com.xqboss.apps.controller.system;

import com.xqboss.apps.dto.aliyun.OssStsDto;
import com.xqboss.apps.service.aliyun.OssService;
import com.xqboss.apps.service.sys.ConfigService;
import com.xqboss.apps.vo.sys.AppProfileVo;
import com.xqboss.common.annotation.Anonymous;
import com.xqboss.common.core.controller.BaseController;
import com.xqboss.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = {"系统配置项管理"})
@Slf4j
@RestController
@RequestMapping("/apps/profile")
public class SysProfileController extends BaseController {

    @Autowired
    private ConfigService configService;
    @Autowired
    private OssService ossService;

    @Anonymous
    @ApiOperation("获取APP配置信息")
    @GetMapping()
    public R<AppProfileVo> profile() {
        AppProfileVo vo = configService.getAppProfile();
        return R.ok(vo);
    }

    @ApiOperation("获取临时oss配置")
    @GetMapping("/oss-config")
    public R getOssStsInfo() {
        OssStsDto stsInfo = ossService.getStsInfo(true);
        return R.ok(stsInfo);
    }
}
